﻿using Authentication.Core.Data;
using Authentication.Model.Interface;
using Authentication.Model.Model;
using System.Collections.Generic;
using System.Linq;

namespace Authentication.Provider
{
    public class BranchProvider : GenericProvider, IBranchProvider
    {
        public List<Branch> RetrieveAllBranch()
        {
            var data = repository.DbContext as AuthenticationEntities;
            var query = from x in data.Branchs
                        select x;
            return query.ToList();
        }
        public Branch RetrieveBranchByDeptParent(string deptParent)
        {
            var data = repository.DbContext as AuthenticationEntities;
            var query = from x in data.Branchs
                        where x.BranchId.Substring(x.BranchId.Length - 3).Equals(deptParent)
                        select x;
            return query.FirstOrDefault();
        }

    }
}
